<?php
/**
 * View EVENTI - index LaFabbrica.org
 * 
 * @author     luigi.pastore (gigi@la-fabbrica.org)
 * @created    17-mag-2011
 * @package    LaFabbrica
 * @copyright  Copyright (c) 2011 Luigi Pastore
 */
?>
<script type="text/javascript">
    //<![CDATA[
     
    $(document).ready(function()
    {

        var pagination = $('#events').pagination({
	    'targetUrl' : '/admin/ajax/list/tourbooks',
	    'orderField' : 'event_id',
	    'orderDir' : 'asc'
	}, function(){
            $('tr[class^="selectable"]').click(function(){
                $(this).siblings().removeClass('selected');
                $(this).toggleClass('selected');
            })            
        });
        
        $( "#searchField" ).keyup( function() {
            if($(this).val().length >= 3)
            {
                var pagination = $('#events').pagination({
                    'targetUrl' : '/admin/search/events/'+ $(this).val(),
                    'orderField' : 'event_id',
                    'orderDir' : 'asc',
                    'perPage' : 2
                }, function(){
                    $('tr[class^="result"]').click(function(){
                        $(this).siblings().removeClass('selected');
                        $(this).toggleClass('selected');
                    })            
                });
            }
            else if($(this).val().length == 0)
            {
                var pagination = $('#events').pagination({
                    'targetUrl' : '/admin/ajax/list/events',
                    'orderField' : 'event_id',
                    'orderDir' : 'asc'
                }, function(){
                    $('tr[class^="result"]').click(function(){
                        $(this).siblings().removeClass('selected');
                        $(this).toggleClass('selected');
                    })            
                });            
            }
        });        
    });

    //]]>
</script>

<div id="content">
    <div id="summary" class="tourbook">
	<div class="head">
	    <h2>Tourbook</h2>
	</div>
	<div class="body">Qui puoi compilare e stampare il Tourbook degli eventi</div>
    </div>
    <table cellspacing="0" class="log clearfix list tourbook">
        <caption>
            Tot: <strong><?php echo $this->count_events ?></strong> elementi presenti.
            <div class="searchBox">
                <label class="search">Cerca</label>
                <input class="search" id="searchField" class="text" type="search" value="">
            </div>
        </caption>
        <thead>
            <tr>
                <td class="pagination" colspan="5">
                    <a class="prev" href="javascript: void(0);">&nbsp;</a>
                    <span class="loader">Sto caricando...</span>
                    <a class="next" href="javascript: void(0);">&nbsp;</a>
                </td>
            </tr>
                
        </thead>
        <tbody id="events">
            
        </tbody>
        <tfoot>
            <tr>
                <td class="pagination" colspan="5">
                    <a class="prev" href="javascript: void(0);">&nbsp;</a>
                    <span class="loader">Sto caricando...</span>
                    <a class="next" href="javascript: void(0);">&nbsp;</a>
                </td>
            </tr>
        </tfoot>
    </table> 
</div>